package homework.day319.demo1;

public class Main {
    public static void main(String[] args) {
        Animal animal1 = new Animal("狸花猫");
        Animal animal2=new Dog("边牧","黑白");
        Animal animal3=new SmallDog("金毛","金色",1);

        testAnimal(animal1);
        testAnimal(animal2);
        testAnimal(animal3);

        testDog(animal1);
        testDog(animal2);
        testDog(animal3);

        testSmallDog(animal1);
        testSmallDog(animal2);
        testSmallDog(animal3);
    }
    public static boolean testAnimal(Object object){
        if(object instanceof Animal){
            Animal animal = (Animal) object;
            animal.eat();
            System.out.println(animal);
            return true;
        }
        return false;
    }

    public static boolean testDog(Object object){
        if(object instanceof Dog){
            Dog dog = (Dog) object;
            dog.call();
            System.out.println(dog);
            return true;
        }
        return false;
    }
    public static boolean testSmallDog(Object object){
        if(object instanceof SmallDog){
            SmallDog smallDog = (SmallDog) object;
            smallDog.sleep(10);
            System.out.println(smallDog);
            return true;
        }
        return false;
    }

}
